package com.excel.util;

import com.excel.enums.LanguageTypeEnum;
import lombok.experimental.UtilityClass;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.util.Strings;
import javax.servlet.http.HttpServletRequest;
import java.util.Optional;

/**
 * @author User
 */
@Slf4j
@UtilityClass
public class NeptuneUtil {

    public static final String PREFIX = "{{{";
    private static final String SUFFIX = "}}}";
    public static final String LOCALE = "language";
    public static final String ACCEPT_LANGUAGE = "Accept-Language";

    public static boolean isNeptuneWords(String content) {
        if (StringUtils.isBlank(content)) {
            return false;
        }
        return content.startsWith(PREFIX) && content.endsWith(SUFFIX);
    }



    public static LanguageTypeEnum getLanguageTypeByCookie(HttpServletRequest request) {
//        LanguageTypeEnum defaultLanguage = LanguageTypeEnum.ZH_CN;
        String acceptLanguage = Optional.ofNullable(request.getHeader(ACCEPT_LANGUAGE)).orElse(Strings.EMPTY);
        return LanguageTypeEnum.ZH_CN;
    }



}
